Skip to content

Prefer using non-deprecated EC OSSL APIs where possible#127190

Merged
PranavSenthilnathan merged 26 commits into
dotnet:mainfrom
PranavSenthilnathan:ossl-deprecations-ec
Jun 11, 2026
Merged

Prefer using non-deprecated EC OSSL APIs where possible#127190
PranavSenthilnathan merged 26 commits into
dotnet:mainfrom
PranavSenthilnathan:ossl-deprecations-ec

Conversation

@PranavSenthilnathan

@PranavSenthilnathan PranavSenthilnathan commented Apr 20, 2026

Copy link
Copy Markdown
Member

Adds new native entry points that use the modern OpenSSL 3.0 EVP_PKEY parameter and keygen APIs for EC key
generation, import, and export, avoiding the deprecated EC_KEY APIs where possible.

On pre-3.0 OpenSSL, the existing EC_KEY code paths are preserved as fallbacks. All new lightup APIs are guarded with
API_EXISTS under FEATURE_DISTRO_AGNOSTIC_SSL.

Unified EC APIs (EC_GROUP_get/set_curve, EC_POINT_get/set_affine_coordinates) are promoted to REQUIRED (available
since OpenSSL 1.1.1, which is the minimum supported version).

@PranavSenthilnathan PranavSenthilnathan self-assigned this Apr 20, 2026
Copilot AI review requested due to automatic review settings April 20, 2026 23:34
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces new OpenSSL 3.0+ EVP_PKEY-based EC key generation/import paths (to avoid deprecated EC_KEY APIs where possible), with managed code updated to prefer these paths and fall back to legacy behavior when needed.

Changes:

  • Add native CryptoNative exports to generate/import EC keys via EVP_PKEY (named curves and explicit parameters).
  • Update managed ECOpenSsl/ECDH code to use the new EVP_PKEY paths first, with legacy EC_KEY fallback.
  • Extend the OpenSSL shim to light up additional OpenSSL 3.0 param-building/keygen APIs.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.h Adds new native API declarations for EVP_PKEY EC key generation/import.
src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Implements EVP_PKEY-based EC keygen and fromdata import (named + explicit).
src/native/libs/System.Security.Cryptography.Native/opensslshim.h Lights up OpenSSL 3.0 param_build and related functions used by new native code.
src/native/libs/System.Security.Cryptography.Native/entrypoints.c Exposes the new native functions via the CryptoNative entrypoint table.
src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs Prefers EVP_PKEY EC keygen/import for OpenSSL 3.0 with fallback to EC_KEY.
src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSslPublicKey.cs Stores/uses EVP_PKEY handles directly instead of wrapping EC_KEY.
src/libraries/Common/src/System/Security/Cryptography/ECDiffieHellmanOpenSsl.Derive.cs Uses EVP_PKEY curve-name detection and imports via new ECOpenSsl helpers.
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.ImportExport.cs Adds P/Invoke wrappers for the new CryptoNative EVP_PKEY EC APIs.

Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs Outdated
Copilot AI review requested due to automatic review settings April 22, 2026 23:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 13 comments.

Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs Outdated
Copilot AI review requested due to automatic review settings April 24, 2026 18:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Comment thread src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/opensslshim.h
Comment thread src/native/libs/System.Security.Cryptography.Native/opensslshim.h
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.h Outdated
Copilot AI review requested due to automatic review settings April 24, 2026 19:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 7 comments.

Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.ImportExport.cs Outdated
Copilot AI review requested due to automatic review settings May 15, 2026 15:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.

Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/libraries/System.Security.Cryptography.OpenSsl/tests/EcDsaOpenSslTests.cs Outdated
Copilot AI review requested due to automatic review settings May 15, 2026 19:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

Comment thread src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs
Comment thread src/libraries/Common/src/System/Security/Cryptography/ECOpenSsl.cs
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Comment thread src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c Outdated
Copilot AI review requested due to automatic review settings June 5, 2026 20:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.

Copilot AI review requested due to automatic review settings June 10, 2026 19:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/native/libs/System.Security.Cryptography.Native/pal_ecc_import_export.c:403

  • CryptoNative_EcKeyCreateByKeyParameters calls EC_KEY_new_by_curve_name / EC_KEY_set_* / EC_KEY_check_key / EC_KEY_free. After making EC_KEY_* LIGHTUP under FEATURE_DISTRO_AGNOSTIC_SSL, these function pointers can be NULL (e.g., OpenSSL built without deprecated EC_KEY APIs), which would crash via a NULL call. Add an API_EXISTS guard early and return a clean failure when EC_KEY APIs are unavailable.
int32_t CryptoNative_EcKeyCreateByKeyParameters(EC_KEY** key, const char* oid, const uint8_t* qx, int32_t qxLength, const uint8_t* qy, int32_t qyLength, const uint8_t* d, int32_t dLength)
{
    if (!key || !oid)
    {
        assert(false);

@PranavSenthilnathan

Copy link
Copy Markdown
Member Author

@dotnet-policy-service rerun

@PranavSenthilnathan PranavSenthilnathan merged commit 397e72c into dotnet:main Jun 11, 2026
116 checks passed
@PranavSenthilnathan PranavSenthilnathan deleted the ossl-deprecations-ec branch June 11, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants